<!DOCTYPE html>
<html>

<head lang="en">
    <title>列表渲染</title>
    <meta charset="utf-8">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <ul id="example-1">
            <li v-for="item in items">
                {{ item.message }}
            </li>
        </ul>
        <ul id="example-2">
            <li v-for="(item, index) in items">
                {{ parentMessage }} - {{ index }} - {{ item.message }}
            </li>
        </ul>
        <ul id="v-for-object" class="demo">
            <li v-for="value in object">
                {{ value }}
            </li>
            <div v-for="(value, name) in object">
                {{ name }}: {{ value }}
            </div>
            <div v-for="(value, name, index) in object">
                {{ index }}. {{ name }}: {{ value }}
            </div>
        </ul>
    </div>
    <script type="text/javascript">
        //v-for遍历数组
        var example1 = new Vue({
            el: '#example-1',
            data: {
                items: [
                    { message: 'Foo' },
                    { message: 'Bar' }
                ]
            }
        });
        var example2 = new Vue({
            el: '#example-2',
            data: {
                parentMessage: 'Parent',
                items: [
                    { message: 'Foo' },
                    { message: 'Bar' }
                ]
            }
        });
        //在v-for中使用对象
        new Vue({
            el: '#v-for-object',
            data: {
                object: {
                    title: 'How to do lists in Vue',
                    author: 'Jane Doe',
                    publishedAt: '2016-04-10'
                }
            }
        })
    </script>
    <style>
    </style>
</body>

</html>